package cn.xuewei.controller;


import cn.xuewei.mapper.CategoryMapper;
import cn.xuewei.response.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/v1/categories/")
public class CategoryController {
    @Autowired
    CategoryMapper categoryMapper;

//     根据一级分类的值请求二级分类
    @RequestMapping("{type}/sub")
    public ResultVO sub(@PathVariable Integer type){
        return ResultVO.ok(categoryMapper.selectByType(type));
    }
    //视频相关分类
    @RequestMapping("video_categories")
    public ResultVO video(){
        return ResultVO.ok(categoryMapper.selectVideo());
    }
    @RequestMapping("category")
    public ResultVO search(){
        return ResultVO.ok(categoryMapper.select());
    }


}
